package com.zzh.wsss.controller;

import com.zzh.wsss.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */

//@Controller+ @ResponseBody
@RestController
//解决跨域
@CrossOrigin//(origins ="http://10.133.69.253:8081" ,allowedHeaders = "*",methods = {},allowCredentials = "true")
public class UserLoginController {

    @Autowired
    private UserLoginService userLoginService;

    //POST、DELETE、PUT、GET
    //添加、 删除、修改、查询


//,produces = "application/json;charset=utf-8"     可防止返回josn乱码
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    //@RequestBody Map<String,Object> map
    private Map<String,Object> userLogin(String username, String password){

        Boolean success=userLoginService.userlogin(username,password);
        Map<String,Object> map=new HashMap<String, Object>();
        if(success==true)map.put("user",userLoginService.userloginmsg(username));
        map.put("success",success);
        return map;
    }

    @RequestMapping(value = "/getUpdataUserMsg",method = RequestMethod.GET)
    private Map<String,Object> getUpdataUserMsg(String username){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("user",userLoginService.userloginmsg(username));
        return map;
    }

    @RequestMapping(value = "/getApplyResult",method = RequestMethod.DELETE)
    private Map<String,Object> getApplyResult(@RequestBody Map<String,String> map){
        return userLoginService.getApplyResult(map.get("username"));
    }

}
